﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Mobile.Models;

namespace Mobile.Controllers
{
    public class SongController : Controller
    {
        //NOTE: SongController was created with code meant to interact with the db, but this functionality was not working due to our
        // our use of a web service and with this code being run locally. Changed it to just revert to our standard views.

        private SongDBContext db = new SongDBContext();

        //
        // GET: /Song/

        public ActionResult Index()
        {
            //return View(db.Songs.ToList());
            return View();
        }

        //
        // GET: /Song/Details/5

        public ActionResult Details(int id)
        {
            //Song song = db.Songs.Find(id);
            //return View(song);
            return View();
        }

        //
        // GET: /Song/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /Song/Create

        [HttpPost]
        public ActionResult Create(Song song)
        {
            try
            {
                return View();
                //db.Songs.Add(song);
                //db.SaveChanges();
                //return RedirectToAction("Index");
            }
            catch
            {
                //return View(song);
                return View();
            }
        }
        
        //
        // GET: /Song/Edit/5
 
        public ActionResult Edit(int id)
        {
            //Song song = db.Songs.Find(id);
            //return View(song);
            return View();
        }

        //
        // POST: /Song/Edit/5

        [HttpPost]
        public ActionResult Edit(Song song)
        {
            try
            {
                // TODO: Add update logic here
                if (ModelState.IsValid)
                {
                    //db.Entry(song).State = System.Data.EntityState.Modified;
                    //db.SaveChanges();
                    //return RedirectToAction("Index");
                    return View();
                }
                return View();
            }
            catch
            {
                return View();
            }
        }
        

        //
        // POST: /Song/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult Delete(int id)
        {
            Song song = null;
            try
            {
                //// Delete Logic
                //song = db.Songs.Find(id);
                //db.Songs.Remove(song);
                //db.SaveChanges();
                //return RedirectToAction("Index");
                return View();
            }
            catch
            {
                return View();
                //return View(song);
            }
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}
